package org.jeecg.modules.job;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.modules.quartz.entity.QuartzJob;
import org.jeecg.modules.quartz.service.IQuartzJobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.List;

@Component
@Slf4j
public class JobStart {
    @Autowired
    private IQuartzJobService quartzJobService;
    @PostConstruct
    public void initQuartz() {
        log.info("initQuartz start");
        QueryWrapper<QuartzJob> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("status", CommonConstant.STATUS_NORMAL);
        List<QuartzJob> quartzJobs = quartzJobService.list(queryWrapper);
        for (QuartzJob quartzJob : quartzJobs) {
            quartzJobService.resumeJob(quartzJob);
        }
        log.info("initQuartz end");
    }

    public static void main(String[] args) {

       String x =  "0^5AU2-2-1/5层 UPS2-2主机输出设备通讯中断".split("\\^")[0];
        System.out.println(x);
    }


}
